#include "SemanticNodeBlockGather.h"
/**
 *  @fn	SemanticNodeBlockGather::SemanticNodeBlockGather(const SyntaxTreeNode *gatherNodeParent,
 *  	SemanticNode *parent)
 * 
 *  @brief	Constructor. 
 * 
 *  @author	Nikola Novak
 *  @date	6/26/2009
 * 
 *  @param	gatherNodeParent	If non-null, the gather node parent.
 *  @param	parent				If non-null, the parent.
 */
SemanticNodeBlockGather::SemanticNodeBlockGather(const SyntaxTreeNode *gatherNodeParent, SemanticNode *parent) : SemanticNode(parent), LabeledNode(gatherNodeParent->Nodes->GetData(0)) {
	const SyntaxTreeNode *theNode = gatherNodeParent->Nodes->GetData(1)->Nodes->GetData(0);
	expression = (theNode->Nodes->GetCount() > 2);
	destroy = (theNode->Nodes->GetData(1)->Nodes->GetCount() > 0);
}
/**
 *  @fn	void SemanticNodeBlockGather::setExpression(SemanticNodeExpression *expression)
 * 
 *  @brief	Sets an expression. 
 * 
 *  @author	Nikola Novak
 *  @date	8/20/2009
 * 
 *  @param	expression	If non-null, the expression.
 */
void SemanticNodeBlockGather::setExpression(SemanticNodeExpression *expression) {
	myExpression = expression;
}
/**
 *  @fn	bool SemanticNodeBlockGather::hasExpression(void)
 * 
 *  @brief	Query if this object has expression. 
 * 
 *  @author	Nikola Novak
 *  @date	8/20/2009
 * 
 *  @return	true if expression, false if not.
 */
bool SemanticNodeBlockGather::hasExpression(void) {
	return expression;
}
/**
 *  @fn	bool SemanticNodeBlockGather::hasDestroy(void)
 * 
 *  @brief	Query if this object has destroy. 
 * 
 *  @author	Nikola Novak
 *  @date	8/20/2009
 * 
 *  @return	true if destroy, false if not.
 */
bool SemanticNodeBlockGather::hasDestroy(void) {
	return destroy;
}
/**
 *  @fn	std::string SemanticNodeBlockGather::toDebugString(int tab)
 * 
 *  @brief	Converts a tab to a debug string. 
 * 
 *  @author	Nikola Novak
 *  @date	6/25/2009
 * 
 *  @param	tab	The tab.
 * 
 *  @return	This object as a std::string.
 */
std::string SemanticNodeBlockGather::toDebugString(int tab) {
	std::ostringstream res;
	for (int i = 0; i < tab; i++)	res << DEBUG_STRING_RAZMAK;
	res << getLabelsDebugString() << ": gather ";
	if (!destroy) res << "and don't destroy ";
	else res << "and destroy ";
	if (!expression) res << "1";
	else res << std::endl << ((SemanticNode *)myExpression)->toDebugString(tab + 1);
	return res.str();
}
